package com.ram.controller;

import com.ram.pojo.AssetInventoryDetail;
import com.ram.pojo.Result;
import com.ram.service.AssetInventoryDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/asset/inventoryDetail")
public class AssetInventoryDetailController {
    @Autowired
    private AssetInventoryDetailService detailService;

    @GetMapping("/list")
    public Result list(@RequestParam Integer inventoryId) {
        return Result.success(detailService.list(inventoryId));
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id) {
        return Result.success(detailService.getById(id));
    }

    @PostMapping
    public Result add(@RequestBody AssetInventoryDetail detail) {
        detailService.add(detail);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        detailService.deleteById(id);
        return Result.success();
    }

    /**
     * 盘点结果统计
     */
    @GetMapping("/stat/result")
    public Result statResult(@RequestParam Integer inventoryId) {
        return Result.success(detailService.statResultByInventoryId(inventoryId));
    }

    /**
     * 分类盘点结果统计
     */
    @GetMapping("/stat/category")
    public Result statCategory(@RequestParam Integer inventoryId) {
        return Result.success(detailService.statCategoryResultByInventoryId(inventoryId));
    }
} 